package collection;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

public class IteratorDemo {
    public static void main(String[] args) {
        Collection<String> c = new ArrayList<>();
        c.add("asd");
        c.add("#");
        c.add("qwe");
        c.add("#");
        c.add("zxc");
        c.add("#");
        c.add("rty");

        System.out.println("c:"+c);

        Iterator<String> it  = c.iterator();
        while (it.hasNext()){
            String s = it.next();
            System.out.println(s);
            if ("#".equals(s)){
                it.remove();
            }

        }
        System.out.println("c:"+c);

    }
}
